/*
*
posts api 路由
*/

var _ = require('lodash');

var models = require('../models/index');
var UserModel = models.User;

var config = require('../config');



var index = function(req,res,next){

    var page = parseInt(req.query.page,10) || 1;
    page= page > 0 ? page : 1;
    var limit = Number(req.query.limit) || config.list_posts_count;
    var options = {skip:(page-1)*limit,limit:limit,sort:'_id'};

    UserModel.find({},'',options,function(err,doc){


        if(err){
            return next(err);
        }
        res.send({success:true,
            data:doc
        })
    });

}

exports.index = index;